package com.gpframework.module.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gpframework.common.constant.Constants;
import com.gpframework.module.common.domain.*;
import com.gpframework.module.common.domain.req.CommonWxUserReq;
import com.gpframework.module.common.domain.vo.*;
import com.gpframework.module.common.mapper.CommonWxUserMapper;
import com.gpframework.module.common.service.*;

import org.springframework.stereotype.Service;

import java.util.*;


/**
 * @ClassName CommonWxUser
 * @Author gpframework
 * @Date 2022-04-07
 * @Version 1.0.0
 * @Description 微信用户Service业务层处理
 */
@Service
public class CommonWxUserServiceImpl extends ServiceImpl<CommonWxUserMapper, CommonWxUser> implements ICommonWxUserService {

    /**
     * @Description 查询列表返回VO 用于返回给前端的列表接口
     * @Author gpframework
     * @Date 2022-04-07
     * @Param [lqw]
     * @Return List<CommonWxUserVo>
     */
    @Override
    public List<CommonWxUserVo> listVo(QueryWrapper<CommonWxUser> lqw) {
        return this.baseMapper.listVo(lqw);
    }

    /**
     * @Description 通过查询详情VO 用于返回给前端的列详情接口
     * @Author gpframework
     * @Date 2022-04-07
     * @Param [id]
     * @Return CommonWxUserVo
     */
    @Override
    public CommonWxUserVo getVoById(Long id) {
        return this.baseMapper.getVo(id);
    }
    /**
     * 跟进品牌系统用户id获取用户信息
     *
     * @param commonWxUserReq
     * @return
     */
    @Override
    public CommonWxUser findByBrandUserId(CommonWxUserReq commonWxUserReq) {
        QueryWrapper<CommonWxUser> lqw = new QueryWrapper<>();
        lqw.eq("del_status", Constants.DEL_STATUS_FALSE);
        lqw.eq("brand_id", commonWxUserReq.getBrandId());
        lqw.eq("brand_user_id", commonWxUserReq.getBrandUserId());
        return this.baseMapper.selectOne(lqw);
    }
}
